//
//  DetailViewController.m
//  FlowerRainGround
//
//  Created by 阿仁欧巴 on 16/4/20.
//  Copyright © 2016年 lanou. All rights reserved.
//

#import "DetailViewController.h"

@interface DetailViewController ()

@property (strong, nonatomic) IBOutlet UIWebView *webView;
@property (strong, nonatomic) IBOutlet UIView *bottomView;
@property (strong, nonatomic) IBOutlet UILabel *timeLabel;
@property (strong, nonatomic) IBOutlet UILabel *watchLabel;
@property (strong, nonatomic) IBOutlet UILabel *favoLabel;

@end

@implementation DetailViewController


- (void)loadData
{
    if (self.model) {
        NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:self.model.pageUrl]];
        [self.webView loadRequest:request];
        self.watchLabel.text = [self.model.read stringValue];
        self.favoLabel.text = [self.model.favo stringValue];
        NSArray *array = [self.model.createDate componentsSeparatedByString:@" "];
        self.timeLabel.text = array[0];

    } else {
        NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:self.videoModel.sharePageUrl]];
        [self.webView loadRequest:request];
        self.watchLabel.text = [self.videoModel.justRead stringValue];
        self.favoLabel.text = [self.videoModel.order stringValue];
        NSArray *array = [self.videoModel.createDate componentsSeparatedByString:@" "];
        self.timeLabel.text = array[0];

    }

}

- (void)createShareButton
{
    //创建分享按钮
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    button.frame = CGRectMake(0, 0, 30, 30);
    [button setImage:[UIImage imageNamed:@"分享"] forState:UIControlStateNormal];
    [button setImage:[UIImage imageNamed:@"分享2"] forState:UIControlStateHighlighted];
    [button addTarget:self action:@selector(share:) forControlEvents:UIControlEventTouchUpInside];
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:button];
}


- (void)viewDidLoad {
    [super viewDidLoad];
    [self loadData];
    [self createShareButton];
    
    
    
    // Do any additional setup after loading the view.
}

#pragma mark ---收藏按钮----


- (IBAction)collectionButton:(id)sender {

    
    
    
}


//分享按钮点击事件
- (void)share:(UIButton *)button
{




}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
